function checkToken({
	cbIfHasToken = null,
	pathForGoinBack = '',
	isTabBarPage = true
} = {}) {
	let token = uni.getStorageSync('token')
	if (token) {
		if (typeof cbIfHasToken === 'function') {
			cbIfHasToken()
		}
	} else {
		uni.switchTab({
			url: "../user/user",
			success: res => {
				uni.setStorageSync('pathForGoinBack', pathForGoinBack)

				uni.setStorageSync('isTabBarPage', isTabBarPage)

				setTimeout(() => {
					uni.showToast({
						title: '请先登录',
						icon: 'none'
					})
				})
			}
		})

	}
}

function goBackAfterLogin() {
	let pathForGoinBack = uni.getStorageSync('pathForGoinBack')
	let isTabBarPage = uni.getStorageSync("isTabBarPage")

	//判断登录后要不要跳转到某个页面
	if (pathForGoinBack) {
		//判断往回跳转的页面的类型
		if (isTabBarPage) {
			uni.switchTab({
				url: pathForGoinBack,
				success: () => {
					uni.removeStorageSync('pathForGoinBack')
					uni.removeStorageSync('isTabBarPage')
				}
			})
		} else {

		}
	}
}
export {
	checkToken,
	goBackAfterLogin
}
